package com.flying.server.network;

import com.flying.server.network.msg.ORMsg;

import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;


public class MsgDispatchHandler extends SimpleChannelUpstreamHandler{
	
	@Override
	public void messageReceived(
            ChannelHandlerContext ctx, MessageEvent e) throws Exception {
		
		System.out.println("messageReceived");
		
		if (e.getMessage() instanceof ORMsg)
		{
			ORMsg msg = (ORMsg) e.getMessage();
			msg.setChannel(e.getChannel());
			NetworkServer.getInstance().onReceivedMsg(msg);
		}
		
		super.messageReceived(ctx, e);
    }
}
